<link href="{$base_dir}css/autocomplete.css" type="text/css" rel="stylesheet"/>
<script type="text/javascript" src="{$base_dir}js/jquery.form.js"></script>
<script type="text/javascript" src='{$base_dir}js/jquery.autocomplete.lhv.js'></script>
<script type="text/javascript" src="{$base_dir}js/selectboxes.js"></script>
<script type="text/javascript" src="{$base_dir}js/AJAX_AddPatient.js"></script>

{literal}
<script type="text/javascript">
	$(document).ready(function(){
		// From parent page
		$('div#barLoading').hide();
		$('div#pageContent').show();
	});
</script>
{/literal}
<input type="hidden" id="viewPage" value="1"/>
<div id='viewDemographics'>
	<input type="hidden" name="person_id" id="person_id" value="{$person->getId()}">
	<table cellspacing="0" cellpadding="0" class='grid' style='width: 100%; margin-bottom: 20px;'>
		<caption>{translate}Patient's information detail{/translate}</caption>
	    <tr>
	        <td class="form_label" width="120px">{translate}Full name{/translate}</td>
	        <td class="form_input" width="220px">{$person->getName()}</td>
	        <td class="form_label" width="120px">{translate}Gender{/translate}</td>
	        <td class="form_input" width="150px">{if $person->getGender()=="male" } {translate}Male{/translate} {elseif $person->getGender()=="female"} {translate}Female{/translate} {/if}</td>
	    	<td class="form_label" width="120px">{translate}Nationality{/translate}</td>
	        <td class="form_input">{$nationality->getLocalizedText('name')}</td>
	    </tr>
	    <tr>
	        <td class="form_label">{translate}Date of birth{/translate}</td>
	        <td class="form_input"><span id="birth_day">{$person->getLocalizedDate('date_of_birth','medium')}</span>&nbsp;&nbsp;({translate}Age{/translate}&nbsp;&nbsp;<span id="age">{$person->getAge()}</span>)</td>
	       	<td class="form_label">{translate}Phone number{/translate}</td>
	        <td class="form_input">{$person->getPhoneNumber()}</td>
	        <td class="form_label">Email</td>
	        <td class="form_input">{$person->get('email')}</td>
	    </tr>
	    <tr>
	        <td class="form_label">{translate}Address{/translate}</td>
	        <td class="form_input" colspan="5">{$person->getAddress()}</td>
	    </tr>
	    <tr class='last'>
	        <td class="form_label">{translate}Career{/translate}</td>
	        <td class="form_input">{$career->getLocalizedText('name')}</td>
	        <td class="form_label">{translate}Working place{/translate}</td>
	        <td class="form_input" colspan="3">{$person->getWorkingPlace()}</td>
	    </tr>
	</table>

	<table cellspacing="0" cellpadding="0" class='grid' style='width: 100%;'>
		<caption>{translate}Insurance and relative information{/translate}</caption>
    	{if ($insurance->getInsuranceCode() != '')}
		<tr>       
			<td class="form_label" style='width: 150px;'>{translate}Medicial insurance No{/translate}</td>
			<td class="form_input" style='width: 190px;'>{$insurance->getInsuranceCode()} </td>
			<td class="form_label" style='width: 120px;'>{translate}Issue date{/translate}</td>
			<td class="form_input" style='width: 150px;'>{$insurance->getLocalizedDate('date_issued', 'medium')}</td>
			<td class="form_label" style='width: 120px;'>{translate}Expired date{/translate}</td> 
			<td class="form_input">{$insurance->getLocalizedDate('date_expired', 'medium')}</td>
		</tr>
		<tr>
			<td class="form_label">{translate}Medicial insurance type{/translate}</td>
			<td class="form_input" colspan="5">{$insurance->getInsuranceTypeText()}</td>
		</tr>
		<tr>
			<td class="form_label">{translate}Place of registered examination{/translate}</td>
			<td class="form_input" colspan="5">{$insurance->getRegisteredHospitalName()}</td>
		</tr>
 		{else}
    	<tr>
    		<td colspan="6" class="form_input">{translate}Patient is not supported by medicial insurance{/translate}</td>
    	</tr>
    	{/if}
	    <tr>
	        <td class="form_label" style='width: 150px;'><i>{translate}Relative name{/translate}</i></td>
	        <td class="form_input" style='width: 190px;'>{$patient->getRelativeName()}</td>
	        <td class="form_label" style='width: 120px;'>{translate}Phone number{/translate}</td>
	        <td class="form_input" colspan="3">{$patient->getRelativeNumber()}</td>
	    </tr>
	    <tr class='last'>
	        <td class="form_label"><i>{translate}Address{/translate}</i></td>
	        <td class="form_input" colspan="5">{$patient->getRelativeAddress()}</td>
	    </tr>
	</table>
    <div style='margin-top: 20px; text-align: right'>
    	<a href="javascript:switchDiv('viewDemographics', 'editDemographics');" class="button_link">{translate}Edit demographic information{/translate}</a>
    </div>

</div>

<div id='editDemographics' style='display: none;' >	
	<span id='statusMessage' class='formAlertMsg'></span><br/>	
	<form name="editDemographicsForm" id="editDemographicsForm">
		<input type="hidden" name="person[person_id]" value="{$person->getId()}">	
		<div id="patientDetailsInfo">
			<table cellspacing="0" cellpadding="0" class='grid' style='width: 100%'>
		    	<caption>{translate}Patient's information detail{/translate}</caption>
		     	<tr>
		            <td class="form_label" style='width: 120px;'>{translate}Full name{/translate} *</td>
		            <td class="form_input" style='width: 220px;'><input id="personName" name="person[name]" type="text" value="{$person->getName()}" style="width: 188px;"/></td>
		            <td class="form_label" style='width: 120px;'>{translate}Gender{/translate} *</td>
		            <td class="form_input" style='width: 150px;'>
		                <input id='genderMale' type="radio" name="person[gender]" value="male" {if $person->getGender() == male}checked="checked"{/if} /><span class='label'>{translate}Male{/translate}</span>&nbsp;&nbsp;
		                <input id='genderFemale' type="radio" name="person[gender]" value="female" {if $person->getGender() == female}checked="checked"{/if} /><span class='label'>{translate}Female{/translate}</span>	                	                		               	                
		            </td>
		            <td class="form_label" style='width: 120px;'>{translate}Nationality{/translate}</td>
		           	<td class="form_input" style='width: 150px;'>
		           		<select name="person[nationality]" id="nationality" style="width: 125px;">
		           			{html_options options=$countryList selected=$person->get('nationality')}
		           		</select>
		           	</td>
		       	</tr>
		       	<tr>
		           	<td class="form_label">{translate}Date of birth/Age{/translate} *</td>
		           	<td class="form_input">
	              		<input name="person[DOB_{$datePart_0}]" id="DOB_{$datePart_0}" type="text" value="{$birthDays.0}" style='width: 30px;' onkeyup="return autoTab(this, 2, 'DOB_{$datePart_1}')" />
	              		<input name="person[DOB_{$datePart_1}]" id="DOB_{$datePart_1}" type="text" value="{$birthDays.1}" style='width: 30px;' onkeyup="return autoTab(this, 2, 'birthday')" />
	              		<input name="person[DOB_{$datePart_2}]" id="birthday" type="text" value="{$birthDays.2}" style='width: 58px;'>&nbsp;-
	              		<input name="person_age" id="person_age" type="text" value="{$person->getAge()}" style='width: 30px;'/>
	               		<br/>
		               	<span class="label" style="width: 21px; color: #AAA;">({$datePart_0}-{$datePart_1}-{$datePart_2})</span>
		            </td>
		          	<td class="form_label">{translate}Phone number{/translate}</td>
		            <td class="form_input">
		                <input name="person[phone_number]" id="person_phone_number" type="text" value="{$person->getPhoneNumber()}" style='width: 120px;'/>
		            </td>
		            <td class="form_label">Email</td>
		            <td class="form_input">
		            	<input name="person[email]" id="person_email" type="text" value="{$person->get('email')}" style='width: 120px;'/>
		            </td>   
		       	</tr>
		        <tr>
		            <td class="form_label">{translate}Address{/translate}</td>
		            <td class="form_input" colspan="5">
		                <input name="address[street]" id='adrStreet' type="text" value="{$person->getStreet()}" style="width: 188px;"/>&nbsp;                   
		            	<select name="address[province_id]" id="province_id" style="width: 145px;">
							<option value="0" label="- - -">- {translate}Province{/translate} -</option>
							{html_options options=$provinceList selected=$person->getProvinceId()}
						</select>
						<select name="address[district_id]" id="district_id" style="width: 145px;">
							{html_options options=$districtList selected=$person->getDistrictId()}
						</select>&nbsp;&nbsp;
						<span class="label">{translate}Ward{/translate}</span>
						<input name="address[ward_name]" id="ward_name" type="text" style="width: 120px;" value="{$person->getWardName()}"/>
		            </td>
		       	</tr>
		       	 <tr class='last'>
		        	<td class="form_label">{translate}Career{/translate}</td>
		            <td class="form_input">
		                <select name="person[career_id]" id="career_id" style="width: 145px;">
		                	<option value="-1" selected="selected">- - -</option>
							{html_options options=$careerList selected=$person->getCareer()}
		                </select>
		            </td>  
					<td class="form_label">{translate}Working place{/translate}</td>
					<td class="form_input" colspan='3'>
					    <select name="person[workingplace_province_id]" id="workingProvince" style="width: 145px;">
					        <option value="-1" label="- - -">- {translate}Province{/translate} -</option>
					        {html_options options=$provinceList selected=$person->getWorkingProvinceId()}
					    </select> 
					    {if ($countList > 0)} 
						<select name="person[workingplace_district_id]" id="workingDistrict" style="width: 145px;">
							{html_options options=$wokingDistrictList selected=$person->getWorkingDistrictId()}									
						</select> 
						{else} 
						<select name="person[workingplace_district_id]" id="workingDistrict" style="width: 145px;">
							<option label="- - -">- {translate}District{/translate} -</option>
						</select> 
						{/if}
					</td>
		        </tr>
		     </table>
		</div>
		
		<div id="insuranceAndRelations" style='margin-top: 20px;'>
			<table cellspacing="0" cellpadding="0" class='grid' style='width: 100%'>
				<caption>{translate}Insurance and relative information{/translate}</caption>
		      	<tr>
					<td class="form_label" style='width: 120px;'>{translate}Medicial insurance number (if have){/translate}</td>
					<td class="form_input" style='width: 220px;'>
		            	<input id="insuranceCode" name="insurance[insurance_code]" type="text" value="{$insurance->getInsuranceCode()}" style="width: 188px;"/> 
					</td>
					<td class="form_input" style='width: 120px;'>&nbsp;</td>
					<td class="form_label" style='width: 150px;'>{translate}Insurance type{/translate}</td>
					<td class="form_input" style='width: 150px;'>
						<select name="insurance[insurance_type]" id="insurance_type" style="width: 125px;">
					    	<option>- - {translate}Type{/translate} - -</option>
							<option value="required" {if $insurance->get('insurance_type') == 'required'} selected="selected"{/if}>{translate}Required{/translate}</option>
							<option value="volunteered" {if $insurance->get('insurance_type') == 'volunteered'} selected="selected"{/if}>{translate}Volunteered{/translate}</option>
					   	</select>
					</td>
					<td class="form_input" style='width: 120px;'>&nbsp;</td> 
				</tr>
		   		<tr>
		            <td class="form_label">{translate}Issue date / Expired date{/translate}</td>
		            <td class="form_input" colspan='2'>
		                <input name="insurance[issued_{$datePart_0}]" id="issued_{$datePart_0}" type="text" value="{$issuedDate.0}" style="width: 30px;">
		                <input name="insurance[issued_{$datePart_1}]" id="issued_{$datePart_1}" type="text" value="{$issuedDate.1}" style="width: 30px;">
		                <input name="insurance[issued_{$datePart_2}]" id="insurance_date_issued" type="text" value="{$issuedDate.2}" style="width: 58px;">&nbsp;-                  
		                <input name="insurance[expired_{$datePart_0}]" id="expired_{$datePart_0}" type="text" value="{$expiredDate.0}" style="width: 30px;">
		                <input name="insurance[expired_{$datePart_1}]" id="expired_{$datePart_1}" type="text" value="{$expiredDate.1}" style="width: 30px;">
		                <input name="insurance[expired_{$datePart_2}]" id="insurance_date_expired" type="text" value="{$expiredDate.2}" style="width: 58px;">
		                <br/>
		               	<span class="label" style="width: 21px; color: #AAA;">({$datePart_0}-{$datePart_1}-{$datePart_2})</span>
		            </td>
		        	<td class="form_label">{translate}Place of registered examination{/translate}</td>
		        	<td class="form_input" colspan='2'><input type="text" name="registeredHospital" id="registeredHospital" value="{if $insurance->getInsuranceCode() != ''}{$insurance->getRegisteredHospitalName()}{/if}" style="width: 220px;"></td>
		        </tr>    
		        <tr>
		            <td class="form_label">{translate}Relative name{/translate}</td>
		            <td class="form_input" colspan='2'><input id="patient_relative_name" name="patient[relative_name]" type="text" value="{$patient->getRelativeName()}" style="width: 188px;"/></td>
		            <td class="form_label">{translate}Phone number{/translate}</td>
		            <td class="form_input" colspan='2'>
		                <input id="patient_relative_number" name="patient[relative_number]" type="text" value="{$patient->getRelativeNumber()}" style="width: 120px;"/>
		            </td>
		        </tr>
		        <tr class='last'>
		            <td class="form_label">{translate}Address{/translate}</td>
		            <td class="form_input" colspan='5'>
		                <input id="patient_relative_address" name="patient[relative_address]" type="text" value="{$patient->getRelativeAddress()}" style="width: 480px;"/>
		            </td>
		        </tr>						          			 	
		    </table>
	    </div>
		<div style='margin-top: 20px; text-align: right'>
			<a href="javascript:savePatient()" id="savePatient" class="button_link" onclick="return isReadyToSubmit();">{translate}Save{/translate}</a>
			<a href="javascript:switchDiv('viewDemographics', 'editDemographics');" class="button_link">{translate}Cancel{/translate}</a>
		</div>
    </form>
</div>